import { createBrowserRouter, createRoutesFromElements, Navigate, Route } from "react-router-dom";
import Home from "../pages/Home";
import Login from "../pages/Login";
import Layouts from "../pages/Layout";
import ErrorPage from "../pages/ErrorPage";
import Views from "../pages/Views";

const { ListPage, userManagePage, LogsManagePage, ViewsManagePage, Dnd } = Views

const router = createBrowserRouter(

    createRoutesFromElements(
        <>
            <Route path="/" element={<Navigate to="/dnd" />}></Route>
            <Route path="/layout" element={<Layouts />}>
                <Route path='home' element={<Home />} />
                <Route path='cardlist' element={<ListPage.CardList />} />
                <Route path='querylist' element={<ListPage.QueryList />} />
                <Route path='roleList' element={<userManagePage.roleList />} />
                <Route path='userlist' element={<userManagePage.userList />} />
                <Route path='departmentlist' element={<userManagePage.departmentList />} />
                <Route path='loginlogs' element={<LogsManagePage.loginLogs />} />
                <Route path='viewsmanage' element={<ViewsManagePage />} />
            </Route>
            <Route path='/login' element={<Login />}></Route>
            <Route path='*' element={<ErrorPage />}></Route>
            <Route path="/dnd" element={<Dnd />}></Route>
        </>
    )


)

export default router